home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / et / et3_0-a1.lha / et3 / src / Bitmap.h < prev    next >
C/C++ Source or Header  |  1992-08-24  |  2KB  |  80 lines

  1. #ifndef Bitmap_First
  2. #ifdef __GNUG__
  3. //pragma once
  4. #pragma interface
  5. #endif
  6. #define Bitmap_First
  7.  
  8. #include "Types.h"
  9. #include "Point.h"
  10. #include "Ink.h"
  11.  
  12. class DevBitmap;
  13.  
  14. const int cPartPixelChanged= 12345;
  15.  
  16. //---- Bitmap ----------------------------------------------------------------
  17.  
  18. class Bitmap : public Ink {
  19. protected:
  20.     DevBitmap *dbm, *mask;
  21.     
  22.     void seedfill(int x, int y, u_int seed, u_int val);
  23.  
  24. public:
  25.     MetaDef(Bitmap);
  26.  
  27.     Bitmap(Point sz, u_short depth= 1);
  28.     Bitmap(Point sz, u_short *data, u_short depth= 1);
  29.     Bitmap(int sz, u_short *data, u_short depth= 1);
  30.     Bitmap(DevBitmap *);
  31.     Bitmap(const char *name);
  32.     ~Bitmap();
  33.     
  34.     DevBitmap *GetDevBitmap()
  35.     { return dbm; }
  36.     DevBitmap *GetDevMask()
  37.         { return mask; }
  38.     void SetDevBitmap(DevBitmap*);
  39.     void SetDevMask(DevBitmap*);
  40.  
  41.     void SetInk(Port *p);
  42.     void SetPixel(u_int x, u_int y, u_int value);
  43.     u_int GetPixel(u_int x, u_int y);
  44.     void Fill(u_int val);
  45.     void SeedFill(Point, u_int val);
  46.     void Clear()
  47.     { Fill(0); }
  48.     int GetDepth();
  49.     Point Size();
  50.     int ShortsPerLine();
  51.     int BytesPerLine();
  52.     int Shorts()
  53.     { return ShortsPerLine() * Size().y; }
  54.     int Bytes()
  55.     { return Shorts() * 2; }
  56.     OStream& PrintOn(OStream&);
  57.     IStream& ReadFrom(IStream&);
  58.     Object *deepclone();
  59. };
  60.  
  61. class SmartBitmap {
  62.     Point size;
  63.     u_short *bits;
  64.     Bitmap *bm;
  65.     const char *name;
  66. public:
  67.     SmartBitmap(const Point &s, u_short *b)
  68.     { size= s; bits= b; }
  69.     SmartBitmap(const char *nm)
  70.     { name= nm; }
  71.     ~SmartBitmap()
  72.     { SafeDelete(bm); }
  73.     Bitmap *MakeBitmap();
  74.     operator Bitmap* ()
  75.     { return bm ? bm : MakeBitmap(); }
  76. };
  77.  
  78. #endif
  79.  
  80.